#include "image_c3100.h"

image_c3100::image_c3100()
{

}

void image_c3100::creat_picture(picture_msg_t *pic)
{
   QImage image(QSize(pic->width,pic->hight),QImage::Format_RGB888);
   image.fill("white");
   QPainter *painter = new QPainter(&image);
   painter->save();
   QPen pen;
   pen.setWidth(1);
   switch (pic->type)
   {
   case color_all:
       for(int i=0;i<pic->width;i++)
       {
           pen.setColor(QColor(i, i, i));
           painter->setPen(pen);
           painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
       }
       break;
   case color_red:
       for(int i=0;i<pic->width;i++)
       {
           pen.setColor(QColor(i, 0, 0));
           painter->setPen(pen);
           painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
       }
       break;
   case color_green:
       for(int i=0;i<pic->width;i++)
       {
           pen.setColor(QColor(0, i, 0));
           painter->setPen(pen);
           painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
       }
       break;
   case color_blue:
       for(int i=0;i<pic->width;i++)
       {
           pen.setColor(QColor(0, 0, i));
           painter->setPen(pen);
           painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
       }
       break;
   case color_special:
       for(int i=0;i<pic->width;i++)
       {
           pen.setColor(QColor(100, 100, 100));
           painter->setPen(pen);
           painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
       }
       break;
   case color_special_w:
       for(int i=0;i<pic->width;i++)
       {
           if(i == 15 || i == 14 || i == 13)
           {
               pen.setColor(QColor(255, 255, 255));
           }
           else
           {
               pen.setColor(QColor(0, 0, 0));
           }
           painter->setPen(pen);
           painter->drawLine(QPointF(i,0),QPointF(i,7));
       }
   }


   painter->restore();
   painter->end();

//   DEBUG_INFO(QString("%1%2.png").arg(pic.patch).arg(pic.file_name));
   image.save(QString("D:/work/share/255_W.png"),"png");

}

void image_c3100::creat_picture_plus(picture_msg_t *pic)
{
    QImage image(QSize(pic->width,pic->hight),QImage::Format_RGB888);
    image.fill("white");
    QPainter *painter = new QPainter(&image);
    painter->save();
    QPen pen;
    pen.setWidth(1);
    switch (pic->type)
    {
    case color_all:
        for(int i=0;i<pic->width;i++)
        {
            pen.setColor(QColor(i, i, i));
            painter->setPen(pen);
            painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
        }
        break;
    case color_red:
        for(int i=0;i<pic->width;i++)
        {
            pen.setColor(QColor(i, 0, 0));
            painter->setPen(pen);
            painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
        }
        break;
    case color_green:
        for(int i=0;i<pic->width;i++)
        {
            pen.setColor(QColor(0, i, 0));
            painter->setPen(pen);
            painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
        }
        break;
    case color_blue:
        for(int i=0;i<pic->width;i++)
        {
            pen.setColor(QColor(0, 0, i));
            painter->setPen(pen);
            painter->drawLine(QPointF(i,0),QPointF(i,pic->width));
        }
        break;
    }


    painter->restore();
    painter->end();

 //   DEBUG_INFO(QString("%1%2.png").arg(pic.patch).arg(pic.file_name));
    image.save(QString("%1/%2.png").arg(pic->patch).arg(pic->file_name),"png");
}
